package com.czxy.servlet;

import cn.itcast.servlet.BaseServlet;
import com.alibaba.fastjson.JSON;
import com.czxy.domain.Category;
import com.czxy.service.CategoryService;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

@WebServlet("/categoryServlet")
public class CategoryServlet extends BaseServlet {


    public void findAll() throws IOException {
        //1.调用Service 获取list
        CategoryService service = new CategoryService();
        List<Category> list = service.findAll();
        //2.list -> json
        String s = JSON.toJSONString(list);
        //3.响应
        getResponse().getWriter().write(s);

    }

}
